package com.partvoyage.client.mvp2.view.information;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.InlineHTML;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.Widget;
import com.partvoyage.client.GooglePlusInformation;
import com.partvoyage.client.mvp2.framework.MVPDisplay;
import com.partvoyage.client.mvp2.framework.MVPPresenter;
import com.partvoyage.client.mvp2.view.information.bean.TagWord;
import com.partvoyage.client.service.projet.ProjetService;
import com.partvoyage.client.service.projet.ProjetServiceAsync;
import com.smartgwt.client.widgets.Canvas;

public class TagCloudPresenter extends MVPPresenter<TagCloudPresenter.Display> {
	protected final ProjetServiceAsync projetService = GWT
			.create(ProjetService.class);

	private List<TagWord> tagWords = new ArrayList<TagWord>();

	public interface Display extends MVPDisplay {
		void addTag(Widget inline);

		void clear();

		LayoutPanel getCloud();

		DecoratorPanel getDec();
	}

	public TagCloudPresenter(final Display display,
			final HandlerManager eventBus) {
		super(display, eventBus);
		bind();
//		init();
	}

	private void init() {
		// tagWords.add(new TagWord("http://www.google.com", "toto", 0));
		// tagWords.add(new TagWord("http://www.google.com", "boiubou", 1));
		// tagWords.add(new TagWord("http://www.google.com", "tiuti", 2));
		// tagWords.add(new TagWord("http://www.google.com", "sdvsvs", 3));
		// tagWords.add(new TagWord("http://www.google.com", "vdfvdf", 4));
		// tagWords.add(new TagWord("http://www.google.com", "dfgdfg", 5));
//		Widget i = new HTML(" <a href='" + "http://www.google.com" + "'>"
//				+ "GOOGLE" + "</a>&nbsp;"), j = new HTML(" <a href='"
//				+ "http://www.google.com" + "'>" + "GOOGLE" + "</a>&nbsp;");
//
//		display.addTag(i);
//		display.addTag(j);
//		int left = display.getDec().getAbsoluteLeft();
//		int top = display.getDec().getAbsoluteTop();
//		int height = display.getDec().getOffsetHeight();
//		int width = display.getDec().getOffsetWidth();
//		System.out.println(left + " " + top + " " + height + " " + width);
//		display.getCloud().setWidgetLeftWidth(i, 0, Unit.PCT, 50, Unit.PCT);
//		display.getCloud().setWidgetBottomHeight(i, 0, Unit.PCT, 50, Unit.PCT);
//		GooglePlusInformation.getInstance().loadImageUrl(null);
		//GooglePlusInformation.getInstance().getMyActivities();
//		display.getCloud().setWidgetLeftWidth(j, 30, Unit.PCT, 50, Unit.PCT);
//		display.getCloud().setWidgetBottomHeight(j, 30, Unit.PCT, 50, Unit.PCT);
	}

	@Override
	protected void bind() {
		// TODO
	}

	@Override
	protected void registerHandler() {
		// TODO
	}

	@Override
	public void go(final HasWidgets container) {
		container.clear();
		container.add(display.asWidget());
	}

	public void go(Canvas container) {
		container.clear();
		container.addChild(display.asWidget());
	}

}
